/*
 * File: E:\Kan\ARM\Projects\Google Code\Umrichter\trunk\SimulinkModelle\slprj\ert\_sharedutils\div_s32.c
 *
 * Code generated for Simulink model 'Fu_Foc'.
 *
 * Model version                  : 1.237
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Sat Apr 20 14:59:02 2013
 */

#include "rtwtypes.h"
#include "rtw_shared_utils.h"

int32_T div_s32(int32_T numerator, int32_T denominator)
{
  int32_T quotient;
  uint32_T absDenominator;
  uint32_T quotientNeedsNegation;
  if (denominator == 0) {
    quotient = numerator >= 0 ? MAX_int32_T : MIN_int32_T;

    /* Divide by zero handler */
  } else {
    absDenominator = (uint32_T)(denominator >= 0 ? denominator : -denominator);
    quotientNeedsNegation = ((numerator < 0) != (denominator < 0));
    absDenominator = absDenominator == 0 ? MAX_uint32_T : (uint32_T)(numerator >=
      0 ? numerator : -numerator) / absDenominator;
    quotient = quotientNeedsNegation ? -(int32_T)absDenominator : (int32_T)
      absDenominator;
  }

  return quotient;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
